//package cn.itsource.zuul1020.config;
//
//import com.alibaba.fastjson.JSON;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.HashMap;
//import java.util.Map;
//
////登录成功结果处理器
//@Component
//public class MyAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
//    @Override
//    public void onAuthenticationSuccess(HttpServletRequest request,
//                                        HttpServletResponse response,
//                                        Authentication authentication) throws IOException, ServletException {
//
//        response.setContentType("application/json;charset=utf-8");//设置编码
//
//        //登录成功才会进入该方法，封装信息返回
//        Map<String, Object> resultJSON = new HashMap<>();
//        resultJSON.put("success", true);
//        resultJSON.put("message", "登录成功");
//        resultJSON.put("data", authentication);
//
//        //结果集返回前端
//        PrintWriter writer = response.getWriter();
//        writer.println(JSON.toJSON(resultJSON));
//        writer.flush();;
//        writer.close();
//    }
//}